<?php
/*
 * 回访买家
 */
class VisitMode extends Data{
    /** @return VisitMode */
    public static function init() {
        return parent::init();
    }
    //新建一条回访记录
    function add($order_id,$user_id,$state = 'create'){
        $data['order_id']=$order_id;
        $data['user_id']=$user_id;
        $data['state']=$state;
        return $this->db->insert('visit',$data) == 1 ? (int)$this->db->insertId():-1;
    }
    //设置回访状态
    function setState($id,$state){
        $time=date('Y-m-d H:i:s',time());
        switch($state){
            case 'inform': $data['inform_time']=$time; break;
            case 'quality':$data['quality_time']=$time;break;
            case 'experience': $data['experience_time']=$time; break;
        }
        $data['state']=$state;
        return $this->db->update('visit',$id,$data) == 1;
    }
} 